home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
C/C++ Users Group Library 1996 July
/
C-C++ Users Group Library July 1996.iso
/
listings
/
v_08_04
/
8n04104a
< prev
next >
Wrap
Text File
|
1990-03-18
|
1KB
|
40 lines
Listing 1
=========
/* Header for memory blocks */
typedef struct MEMBLOCK {
struct MEMBLOCK *mb_next, /* Pointer to next block */
*mb_pres; /* Present block */
int mb_size, /* Size of blocks */
mb_offs; /* Present offset in block */
} MemBlock;
unsigned int iniz_borrow(), deiniz_borrow(), return_borrow();
char *borrow();
/* -------------------------------------------------------- */
/* Initialise memory */
/* Returns the memory ID or zero on error */
unsigned int iniz_borrow(block)
register int block; /* Allocation block size */
{
register MemBlock *p; /* Pointer to block */
/* Get first block */
if((int)(p=(MemBlock *)allocate(block))==0)
return(0);
p->mb_next=NULL; /* No next block */
p->mb_pres=p; /* This is the present block */
p->mb_size=block; /* Record the block size */
p->mb_offs=sizeof(MemBlock); /* Start past this info */
return((unsigned int)p);
}